execute store result score $max ancRandom run data get entity @s Item.tag.Enchantments
scoreboard players set $min ancRandom 1
function anc:random
execute if score $output ancRandom matches 1 run data remove entity @s Item.tag.Enchantments.[0]
execute if score $output ancRandom matches 2 run data remove entity @s Item.tag.Enchantments.[1]
execute if score $output ancRandom matches 3 run data remove entity @s Item.tag.Enchantments.[2]
execute if score $output ancRandom matches 4 run data remove entity @s Item.tag.Enchantments.[3]
execute if score $output ancRandom matches 5 run data remove entity @s Item.tag.Enchantments.[4]
execute if score $output ancRandom matches 6 run data remove entity @s Item.tag.Enchantments.[5]
execute if score $output ancRandom matches 7 run data remove entity @s Item.tag.Enchantments.[6]
execute if score $output ancRandom matches 8 run data remove entity @s Item.tag.Enchantments.[7]
execute if score $output ancRandom matches 9 run data remove entity @s Item.tag.Enchantments.[8]
execute if score $output ancRandom matches 10 run data remove entity @s Item.tag.Enchantments.[9]
execute if score $output ancRandom matches 11 run data remove entity @s Item.tag.Enchantments.[10]
execute if score $output ancRandom matches 12 run data remove entity @s Item.tag.Enchantments.[11]
execute if score $output ancRandom matches 13 run data remove entity @s Item.tag.Enchantments.[12]
execute if score $output ancRandom matches 14 run data remove entity @s Item.tag.Enchantments.[13]
execute if score $output ancRandom matches 15 run data remove entity @s Item.tag.Enchantments.[14]
execute if score $output ancRandom matches 16 run data remove entity @s Item.tag.Enchantments.[15]
execute if score $output ancRandom matches 17 run data remove entity @s Item.tag.Enchantments.[16]
execute if score $output ancRandom matches 18 run data remove entity @s Item.tag.Enchantments.[17]
execute if score $output ancRandom matches 19 run data remove entity @s Item.tag.Enchantments.[18]
execute if score $output ancRandom matches 20 run data remove entity @s Item.tag.Enchantments.[19]
execute if score $output ancRandom matches 21 run data remove entity @s Item.tag.Enchantments.[20]
execute if score $output ancRandom matches 22 run data remove entity @s Item.tag.Enchantments.[21]
execute if score $output ancRandom matches 23 run data remove entity @s Item.tag.Enchantments.[22]
execute if score $output ancRandom matches 24 run data remove entity @s Item.tag.Enchantments.[23]
execute if score $output ancRandom matches 25 run data remove entity @s Item.tag.Enchantments.[24]
execute if score $output ancRandom matches 26 run data remove entity @s Item.tag.Enchantments.[25]
execute if score $output ancRandom matches 27 run data remove entity @s Item.tag.Enchantments.[26]
execute if score $output ancRandom matches 28 run data remove entity @s Item.tag.Enchantments.[27]
execute if score $output ancRandom matches 29 run data remove entity @s Item.tag.Enchantments.[28]
execute if score $output ancRandom matches 30 run data remove entity @s Item.tag.Enchantments.[29]
